package main

import (
	"fmt"
	"math"
)

type Abser interface {
	Abs() float64
	Abs2() float64
}

type MyFloat float64

func (f MyFloat) Abs() float64 {
	if f < 0 {
		return float64(-f)
	}
	return float64(f)
}

func (f *MyFloat) Abs2() float64 {
	return float64(*f)
}

func main() {
	var a Abser
	// 赋值
	f := MyFloat(-math.Sqrt2)
	a = &f // a MyFloat implements Abser
	fmt.Println(a.Abs())
	fmt.Println(a.Abs2())

	if file6, ok := a.(Abser); ok {
		file6 = a
		fmt.Println(file6.Abs())
		fmt.Println("aa")
	}
}
